package org.casscommunity.sights.client.mvp;

import org.casscommunity.sights.client.activity.EditPlaceActivity.EditPlaceActivityFactory;
import org.casscommunity.sights.client.activity.HomeActivity.HomeActivityFactory;
import org.casscommunity.sights.client.activity.PlaceActivity.PlaceActivityFactory;
import org.casscommunity.sights.shared.place.EditPlace;
import org.casscommunity.sights.shared.place.Home;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class AppActivityMapper implements ActivityMapper {

	@Inject
	HomeActivityFactory homeActivityFactory;
	
	@Inject
	PlaceActivityFactory placeActivityFactory;
	
	@Inject
	EditPlaceActivityFactory editPlaceActivityFactory;
	
	public Activity getActivity(Place place) {
		Activity activity = null;
		
		if (place instanceof Home) {
			activity = homeActivityFactory.createActivity((Home) place);
		} else if (place instanceof org.casscommunity.sights.shared.place.Place) {
			activity = placeActivityFactory.createActivity((org.casscommunity.sights.shared.place.Place) place);
		} else if (place instanceof EditPlace) {
			activity = editPlaceActivityFactory.createActivity((EditPlace) place);
		}
		
		return activity;
	}

}
